//
//  ZTTimeOut.h
//  MQTTNetworkTools
//
//  Created by Yahaong on 16/8/3.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import "ZTStatus.h"

@interface ZTTimeOut : ZTStatus{
    
    NSTimer* _timeout;
}

- (void) willRemove;
- (void) timeout;
@end
#define _DEF_MQTT_TIME  (5.0f)
#define _DEF_MQTT_TIMEWait  (0.5f)

//通知代理之前调用
#define _DEF_MQTT_TIME_End \
if (_timeout != nil) { \
[_timeout invalidate]; \
_timeout = nil; \
}

//调用数据之后调用
#define _DEF_MQTT_TIME_Start \
_DEF_MQTT_TIME_End \
_timeout = [NSTimer scheduledTimerWithTimeInterval:_DEF_MQTT_TIME  \
target:self  \
selector:@selector(timeout) \
userInfo:nil  \
repeats:NO];


#define _DEF_MQTT_TIME_END_TRUE(one,two) \
if (one  == two) { \
_DEF_MQTT_TIME_End \
}


#define _DEF_MQTT_TIME_Wait \
_DEF_MQTT_TIME_End \
_timeout = [NSTimer scheduledTimerWithTimeInterval:(_DEF_MQTT_TIMEWait)  \
target:self  \
selector:@selector(timeout) \
userInfo:nil  \
repeats:NO];
